import axios from 'axios'

const request = axios.create({
  withCredentials: false
})
 function getToken() {
    return localStorage.getItem("messageId")
}

request.interceptors.request.use(
    config => {
        if (getToken()) {
            config.headers['Authorization'] = getToken()
        }
        return config
    },
  error => {
    return Promise.reject(new Error(error).message)
  }
)

request.interceptors.response.use(
  response => {
    return response.data
  },
  error => {
    return Promise.reject(new Error(error).message)
  }
)

export default request
